libxl: events: Deregister xenstore watch fd when not needed
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 26 Nov 2014 16:44:52 +0000 (16:44 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 10 Dec 2014 13:48:31 +0000 (13:48 +0000)
commit77a1bf37790d8eb8fb99e7539a1591fdd2988f6d
treeaaa5bc7c99fc042f2e4ec5bef74bf7a73857ce96
parentf49f9b4114d59a67b53322f3f6148ed0db497dca
libxl: events: Deregister xenstore watch fd when not needed

We want to have no fd events registered when we are idle.
In this patch, deal with the xenstore watch fd:

* Track the total number of active watches.
* When deregistering a watch, or when watch registration fails, check
  whether there are now no watches and if so deregister the fd.
* On libxl teardown, the watch fd should therefore be unregistered.
  assert that this is the case.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Ian Campbell <ian.campbell@citrix.com>
Release-Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tools/libxl/libxl.c
tools/libxl/libxl_event.c
tools/libxl/libxl_internal.h